package com.arron.algorithm.tree;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.stream.Collectors;

/**
 * @Classname BtreeTraverse
 * @Date 2020/10/29 11:06
 * @Created by 刘
 */
//输出二叉树的前序遍历，中序遍历，后序遍历
public class BtreeTraverse {

     int i = 0;


     /**
      * 中序遍历
      * @param root
      * @return
      */
     public List<Integer> inorderTraversal(TreeNode root) {
          List<Integer> res = new ArrayList<Integer>();
          inorder(root, res);
          return res;
     }

     public void inorder(TreeNode root, List<Integer> res) {
          if (root == null) {
               return;
          }
          inorder(root.left, res);
          res.add(root.val);
          inorder(root.right, res);
     }



}
